package com.last.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.last.entity.City;
import com.last.entity.RoomInfo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface RoomInfoMapper extends BaseMapper<RoomInfo> {
    //商户的分页加条件查询
    public IPage<RoomInfo> search(@Param("iPage")IPage iPage ,@Param("roomInfo") RoomInfo roomInfo);
    //添加商户
    //@Insert("INSER  INTO room_info VALUES(#{roomName},#{roomStatus},#{typeId},#{pic},#{price},#{roomDescribe},#{homeId})")
    //ublic int save(RoomInfo roomInfo);

    // 获取房间详情信息
    public RoomInfo getRoomInfoByRoomId(@Param("roomId") Integer roomId);

    // 获取房源信息详情
    @Select("SELECT * FROM room_info WHERE room_status<2 AND home_Id=#{homeId}")
    public List<RoomInfo> getHouseDetailInfo(@Param("homeId") Integer homeId);

    //根据home_Id查询area信息
    @Select("SELECT * FROM AREA WHERE area_id=(SELECT area_id FROM home_area WHERE home_id=#{homeId})")
    public City findCityByHomeId(Integer homeId);

    // 获取所有的city
    @Select("select * from city")
    public List<City> getAllCity();
}
